package com.scuec.groupfive.controller;

import com.scuec.groupfive.entity.TaskQuestion;
import com.scuec.groupfive.service.TaskQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/task-questions")
public class TaskQuestionController {

    @Autowired
    private TaskQuestionService taskQuestionService;

    @PostMapping("/batch")
    public ResponseEntity<String> batchAddTaskQuestions(@RequestBody List<TaskQuestion> taskQuestions) {
        try {
            taskQuestionService.batchAddTaskQuestions(taskQuestions);
            return ResponseEntity.ok("批量添加任务题目成功");
        } catch (Exception e) {
            return ResponseEntity.badRequest().body("批量添加任务题目失败: " + e.getMessage());
        }
    }
}